package net.xju.controller;

import net.xju.common.framework.simplemvc.RequestMapping;
import net.xju.common.utils.JSONUtil;
import net.xju.common.utils.Result;
import net.xju.entity.Appointment;
import net.xju.entity.User;
import net.xju.service.AppointmentService;
import net.xju.service.UserService;
import net.xju.service.impl.AppointmentServiceImpl;
import net.xju.service.impl.UserServiceImpl;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.util.List;

@RequestMapping("/api/appointment")
public class ConsultantController {
    private AppointmentService appointmentService = new AppointmentServiceImpl();
    private UserService userService = new UserServiceImpl();

    @RequestMapping("/consultantList.do")
    public void appointmentList(HttpServletRequest req, HttpServletResponse resp) throws UnsupportedEncodingException {
        int consultantId = Integer.parseInt(req.getParameter("consultantId"));
        List<Appointment> appointments = appointmentService.getAppointmentsByConsultantId(consultantId);
        // 这里可以根据 appointments 中的 userId 查询用户信息
        JSONUtil.printByJSON(resp, Result.success(appointments));
    }
}